Load data
##specify variables
#for behavior information
completeFnames =list()
totalData = data.frame()
ic = 1;
#for demographic information
gender = data.frame()
age = data.frame()
ethnicity= data.frame()
race = data.frame()
subID = data.frame()
#for post survey
Postsurvey=data.frame()
Postsurvey_feature = data.frame()
prolificID = data.frame()
confirmationCode = data.frame()
PostsubID=data.frame()
##Getting data from online text output
for (ifiles in 1:length(SameDifferent_fnames)){
tempFile = read.table(paste0(dataPath,SameDifferent_fnames[ifiles]),header = F)
Trials = unlist(strsplit(as.character(tempFile$V1), ";"))
if (length(Trials)>10){
keyNum = data.frame()
accuracy = data.frame()
feature_index = data.frame()
RT = data.frame()
Fir_img = data.frame()
Sec_img = data.frame()
for (i in 1:length(Trials)){
temp = unlist(strsplit(Trials[i],","));
keyNum = rbind(keyNum,as.numeric(temp[2]))
accuracy = rbind(accuracy,as.numeric(temp[4]))
RT = rbind(RT,as.numeric(temp[5]))
feature_index = rbind(feature_index,as.numeric(temp[6]))
Fir_img = rbind(Fir_img,as.numeric(temp[7]))
Sec_img = rbind(Sec_img,as.numeric(temp[8]))
}
data = cbind(keyNum,accuracy,RT, feature_index,Fir_img,Sec_img)
colnames(data) = c("keys","accuracy", "rt","feature_index", "Fimg","Simg")
data = data[-1,]
data$subID = ifiles;
data$trialNum = 1:dim(data)[1];
totalData = rbind(totalData,data)
#Getting demo data
for (ifilesDe in 1:length(Demo_fnames)){
if (unlist(strsplit(SameDifferent_fnames[ifiles],"SameDifferent"))[2]==unlist(strsplit(Demo_fnames[ifilesDe],"demographics"))[2]){ tempDemoFile = read.table(paste0(dataPath,Demo_fnames[ifilesDe]),header = F)
Demo_info = unlist(strsplit(as.character(tempDemoFile$V1), ";"))
gender[ic,1] = unlist(Demo_info[1])
age[ic,1]=unlist(Demo_info[2])
ethnicity[ic,1]=unlist(Demo_info[3])
race[ic,1]=unlist(Demo_info[4])
subID[ic,1]=unlist(ifiles)
}# if
}#for
##Getting post-test data
for (ifilesDe in 1:length(Post_fnames)){
if (unlist(strsplit(SameDifferent_fnames[ifiles],"SameDifferent"))[2]==unlist(strsplit(Post_fnames[ifilesDe],"postsurvey"))[2]){ tempPostFile = read.table(paste0(dataPath,Post_fnames[ifilesDe]),header = F)
###separate feedback and prolific ID
if (dim(tempPostFile)[2]>1){
tempPostFile$y = apply( tempPostFile[,] , 1 , paste , collapse = "" )
Post_info = unlist(strsplit(as.character(tempPostFile$y), ";"))
}else{
Post_info = unlist(strsplit(as.character(tempPostFile$V1), ";"))
}
Postsurvey[ic,1]=unlist(Post_info[1])
prolificID[ic,1] = unlist(Post_info[2])
Postsurvey_feature[ic,1]=feature_index[2,]
confirmationCode[ic,1]=unlist(strsplit(SameDifferent_fnames[ifiles],"SameDifferent"))[2]
PostsubID[ic,1]=unlist(ifiles)
}#if
}#for
completeFnames[ic] =unlist(strsplit(SameDifferent_fnames[ifiles],"SameDifferent"))[2]
ic = ic+1;
}else{
}
}#for
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferent2d92gd20.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographics2d92gd20.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurvey2d92gd20.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferent5NyIyew9.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographics5NyIyew9.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurvey5NyIyew9.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferent6Ry7FyPW.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographics6Ry7FyPW.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurvey6Ry7FyPW.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferent9pceNPdS.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographics9pceNPdS.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurvey9pceNPdS.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentaRQ4yhu7.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsaRQ4yhu7.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyaRQ4yhu7.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentavIh2Uvw.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsavIh2Uvw.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyavIh2Uvw.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentAZHsslHl.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsAZHsslHl.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyAZHsslHl.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentBIctHKvp.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsBIctHKvp.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyBIctHKvp.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentCFl8oC8W.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsCFl8oC8W.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyCFl8oC8W.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentE1htQAkA.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsE1htQAkA.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyE1htQAkA.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentFfRMQSUF.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsFfRMQSUF.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyFfRMQSUF.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentg4JwWhr2.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsg4JwWhr2.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyg4JwWhr2.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferenth9Td4nBL.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsh9Td4nBL.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyh9Td4nBL.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentHyvVzlQ5.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsHyvVzlQ5.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyHyvVzlQ5.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentI7xVbP5Y.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsI7xVbP5Y.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyI7xVbP5Y.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentImcr1rF5.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsImcr1rF5.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyImcr1rF5.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentjSZLEP6w.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsjSZLEP6w.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyjSZLEP6w.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentl0GSsk1b.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsl0GSsk1b.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyl0GSsk1b.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentlni1gMzT.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicslni1gMzT.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveylni1gMzT.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentLQf5l6On.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsLQf5l6On.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyLQf5l6On.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentLwFkVWiT.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsLwFkVWiT.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyLwFkVWiT.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentlZx2DxyF.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicslZx2DxyF.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveylZx2DxyF.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentN6OeZewG.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsN6OeZewG.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyN6OeZewG.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentnDkyvHc3.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsnDkyvHc3.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveynDkyvHc3.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentnn5V6CoS.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsnn5V6CoS.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveynn5V6CoS.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentnp5U0dW3.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsnp5U0dW3.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveynp5U0dW3.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentnqjtdr4U.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsnqjtdr4U.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveynqjtdr4U.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentOavIJUdV.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsOavIJUdV.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyOavIJUdV.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentoXYE0K3r.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsoXYE0K3r.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyoXYE0K3r.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentpTsjGGT2.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicspTsjGGT2.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveypTsjGGT2.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentPzEdMYrh.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsPzEdMYrh.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyPzEdMYrh.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentSgV8v0EC.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentT9Q2O7P0.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsT9Q2O7P0.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyT9Q2O7P0.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentUsuVXoA3.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsUsuVXoA3.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyUsuVXoA3.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentuvZJU3DW.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsuvZJU3DW.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyuvZJU3DW.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentwwHrIjY4.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicswwHrIjY4.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveywwHrIjY4.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentxzSkjmb5.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsxzSkjmb5.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyxzSkjmb5.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentz1XjZzZE.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsz1XjZzZE.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyz1XjZzZE.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentZL3jNxpP.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsZL3jNxpP.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyZL3jNxpP.txt'
## Warning in read.table(paste0(dataPath, SameDifferent_fnames[ifiles]),
## header = F): incomplete final line found by readTableHeader on '/Volumes/
## Macintosh HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/
## Calibration/Prolificdata/newDesignV7_001/SameDifferentZujGQtM6.txt'
## Warning in read.table(paste0(dataPath, Demo_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/demographicsZujGQtM6.txt'
## Warning in read.table(paste0(dataPath, Post_fnames[ifilesDe]), header =
## F): incomplete final line found by readTableHeader on '/Volumes/Macintosh
## HD/Users/Pam_sf_wang/Documents/Perceptual_learning_project/Calibration/
## Prolificdata/newDesignV7_001/postsurveyZujGQtM6.txt'
#demographic information
demographic_information = cbind(gender,age,ethnicity,race,subID)
colnames(demographic_information) = c("Gender","Age","Ethnicity","Race","SubID")
demographic_information$Age = as.numeric(demographic_information$Age)
#save post test survey
postsurvey = cbind(Postsurvey,Postsurvey_feature,prolificID,PostsubID,confirmationCode)
colnames(postsurvey) = c("post_surve","feature","prolificID","SubID","confirm_code")
#write.csv(postsurvey, file = paste0(postsurvey_new_fname,".csv"))
Behavior analysis
summarize = dplyr::summarize
basic = totalData %>% filter(keys>=0)%>% group_by(subID)%>% summarize(num_noresposnes = sum(keys==-1), num_same_resp = sum(keys==1), num_diff_resp = sum(keys==0), num_same_trials =sum(cond==1), num_diff_trials = sum(cond==0),
hit = sum(keys==1&cond==1),
fa= sum(keys==1&cond==0),
cr = sum(keys==0&cond==0),
miss = sum(keys==0&cond==1),
HitRate =sum(keys==1&cond==1)/sum(cond==1),
FARate = sum(keys==1&cond==0)/sum(cond==0),
CRRate = sum(keys==0&cond==0)/sum(cond==0),
MissRate = sum(keys==0&cond==1)/sum(cond==1),
d_p = qnorm(HitRate)-qnorm(FARate))
basic
## # A tibble: 37 x 15
## subID num_noresposnes num_same_resp num_diff_resp num_same_trials
## <int> <int> <int> <int> <int>
## 1 1 0 21 61 21
## 2 2 0 42 42 21
## 3 3 0 37 44 20
## 4 5 0 30 53 21
## 5 6 0 30 54 21
## 6 7 0 28 56 21
## 7 8 0 30 53 21
## 8 9 0 37 47 21
## 9 10 0 27 57 21
## 10 11 0 37 47 21
## # ... with 27 more rows, and 10 more variables: num_diff_trials <int>,
## # hit <int>, fa <int>, cr <int>, miss <int>, HitRate <dbl>,
## # FARate <dbl>, CRRate <dbl>, MissRate <dbl>, d_p <dbl>
#Add d prime to post survey file
postsurvey_d_p = postsurvey
postsurvey_d_p = postsurvey_d_p%>%filter(SubID %in% remainSub)
postsurvey_d_p = cbind(postsurvey_d_p, "dataSubID" = basic$subID, "d_p"=basic$d_p)
ggplot(postsurvey_d_p,aes(x = feature,y = d_p, color = as.factor(feature)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_point(alpha = 0.5, size = 3)+
plotformat
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).

temp = subset(postsurvey_d_p, SubID!=15)
summary(aov(d_p~SubID+feature, temp))
## Df Sum Sq Mean Sq F value Pr(>F)
## SubID 1 0.27 0.2732 0.281 0.599
## feature 1 0.30 0.3042 0.313 0.580
## Residuals 33 32.05 0.9714
#Plotting
basic_longform = gather(basic, response_type, number_resp, HitRate,FARate,CRRate,MissRate)
head(basic_longform)
## # A tibble: 6 x 13
## subID num_noresposnes num_same_resp num_diff_resp num_same_trials
## <int> <int> <int> <int> <int>
## 1 1 0 21 61 21
## 2 2 0 42 42 21
## 3 3 0 37 44 20
## 4 5 0 30 53 21
## 5 6 0 30 54 21
## 6 7 0 28 56 21
## # ... with 8 more variables: num_diff_trials <int>, hit <int>, fa <int>,
## # cr <int>, miss <int>, d_p <dbl>, response_type <chr>,
## # number_resp <dbl>
ggplot(basic_longform, aes(x = response_type, y = number_resp, color = response_type))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
labs(title="Proportaion response type", x = "response type", y = "proportion")+
plotformat

#d-p
ggplot(basic, aes(x = subID, y = d_p, color = as.factor(subID)))+
geom_point(size=3)+
labs(title="d prime", x = "subject", y = "d prime")+
plotformat

ggplot(basic,aes(d_p))+
geom_histogram()+
labs(title="d prime histogram", x = "d prime", y = "counts")+
plotformat
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## Warning: Removed 1 rows containing non-finite values (stat_bin).

check d-p for each feature
#Add d prime to post survey file
postsurvey_d_p = postsurvey
postsurvey_d_p = postsurvey_d_p%>%filter(SubID %in% remainSub)
postsurvey_d_p = cbind(postsurvey_d_p, "dataSubID" = basic$subID, "d_p"=basic$d_p)
ggplot(postsurvey_d_p,aes(x = feature,y = d_p, color = as.factor(feature)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_point(alpha = 0.5, size = 3)+
plotformat
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).

#stats
temp = subset(postsurvey_d_p, !is.infinite(postsurvey_d_p$d_p))
summary(aov(d_p~SubID+feature, temp))
## Df Sum Sq Mean Sq F value Pr(>F)
## SubID 1 0.27 0.2732 0.281 0.599
## feature 1 0.30 0.3042 0.313 0.580
## Residuals 33 32.05 0.9714
#save summary file
write.csv(postsurvey_d_p, file = paste0(postsurvey_new_fname,".csv"))
Remove subjects with low d-p
remain_dp = basic$subID[basic$d_p>d_p_thre]
sprintf("remove d prime lower than %f %i",d_p_thre, length(remain_dp))
## [1] "remove d prime lower than 0.500000 22"
totalData = totalData %>%filter(subID%in%remain_dp)
#check feature number
tempFeature = totalData %>% group_by(subID) %>%summarize(feature = feature_index[1])
sprintf("Feature 1: %i; Feature 2: %i; Feature 3: %i",sum(tempFeature$feature==1),sum(tempFeature$feature==2),sum(tempFeature$feature==3))
## [1] "Feature 1: 7; Feature 2: 6; Feature 3: 9"
##########
basicFeature = totalData %>% filter(keys>=0)%>% group_by(subID,feature_index)%>% summarize(num_noresposnes = sum(keys==-1), num_same_resp = sum(keys==1), num_diff_resp = sum(keys==0), num_same_trials =sum(cond==1), num_diff_trials = sum(cond==0),
hit = sum(keys==1&cond==1),
fa= sum(keys==1&cond==0),
cr = sum(keys==0&cond==0),
miss = sum(keys==0&cond==1),
HitRate =sum(keys==1&cond==1)/sum(cond==1),
FARate = sum(keys==1&cond==0)/sum(cond==0),
CRRate = sum(keys==0&cond==0)/sum(cond==0),
MissRate = sum(keys==0&cond==1)/sum(cond==1),
d_p = qnorm(HitRate)-qnorm(FARate))
basicFeature_longform = gather(basicFeature, response_type, number_resp, HitRate,FARate,CRRate,MissRate)
head(basicFeature_longform)
## # A tibble: 6 x 14
## # Groups: subID [6]
## subID feature_index num_noresposnes num_same_resp num_diff_resp
## <int> <dbl> <int> <int> <int>
## 1 1 3 0 21 61
## 2 2 3 0 42 42
## 3 6 1 0 30 54
## 4 7 3 0 28 56
## 5 9 2 0 37 47
## 6 10 3 0 27 57
## # ... with 9 more variables: num_same_trials <int>, num_diff_trials <int>,
## # hit <int>, fa <int>, cr <int>, miss <int>, d_p <dbl>,
## # response_type <chr>, number_resp <dbl>
ggplot(basicFeature_longform, aes(x = response_type, y = number_resp, color = response_type))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
labs(title="Proportaion response type by feature", x = "response type", y = "proportion")+
plotformat

ggplot(basicFeature, aes(x = subID, y = d_p, group = feature_index, color = as.factor(feature_index)))+
geom_point(size=3)+
plotformat

###########
basicLevel = totalData %>% filter(keys>=0)%>% group_by(subID,level_diff)%>% summarize(num_noresposnes = sum(keys==-1), num_same_resp = sum(keys==1), num_diff_resp = sum(keys==0), num_same_trials =sum(cond==1), num_diff_trials = sum(cond==0),
hit = sum(keys==1&cond==1),
fa= sum(keys==1&cond==0),
cr = sum(keys==0&cond==0),
miss = sum(keys==0&cond==1),
HitRate =sum(keys==1&cond==1)/sum(cond==1),
FARate = sum(keys==1&cond==0)/sum(cond==0),
CRRate = sum(keys==0&cond==0)/sum(cond==0),
MissRate = sum(keys==0&cond==1)/sum(cond==1),
d_p = qnorm(HitRate)-qnorm(FARate))
basicLevel_longform = gather(basicLevel, response_type, number_resp, HitRate,FARate,CRRate,MissRate)
head(basicLevel_longform)
## # A tibble: 6 x 14
## # Groups: subID [1]
## subID level_diff num_noresposnes num_same_resp num_diff_resp
## <int> <dbl> <int> <int> <int>
## 1 1 0 0 20 1
## 2 1 1 0 0 17
## 3 1 2 0 1 14
## 4 1 3 0 0 11
## 5 1 4 0 0 9
## 6 1 5 0 0 6
## # ... with 9 more variables: num_same_trials <int>, num_diff_trials <int>,
## # hit <int>, fa <int>, cr <int>, miss <int>, d_p <dbl>,
## # response_type <chr>, number_resp <dbl>
ggplot(basicLevel_longform, aes(x = response_type, y = number_resp, color = response_type))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~level_diff,nrow = 1)+
labs(title="Proportaion response type by difficulty level", x = "response type", y = "proportion")+
theme_facet()
## Warning: Removed 308 rows containing non-finite values (stat_boxplot).
## Warning: Removed 308 rows containing missing values (geom_point).

###########
basicLevelFeature = totalData %>% filter(keys>=0)%>% group_by(subID,level_diff,feature_index)%>% summarize(num_noresposnes = sum(keys==-1), num_same_resp = sum(keys==1), num_diff_resp = sum(keys==0), num_same_trials =sum(cond==1), num_diff_trials = sum(cond==0),
hit = sum(keys==1&cond==1),
fa= sum(keys==1&cond==0),
cr = sum(keys==0&cond==0),
miss = sum(keys==0&cond==1),
HitRate =sum(keys==1&cond==1)/sum(cond==1),
FARate = sum(keys==1&cond==0)/sum(cond==0),
CRRate = sum(keys==0&cond==0)/sum(cond==0),
MissRate = sum(keys==0&cond==1)/sum(cond==1),
d_p = qnorm(HitRate)-qnorm(FARate))
basicLevelFeature_longform = gather(basicLevelFeature, response_type, number_resp, HitRate,FARate,CRRate,MissRate)
head(basicLevelFeature_longform)
## # A tibble: 6 x 15
## # Groups: subID, level_diff [6]
## subID level_diff feature_index num_noresposnes num_same_resp
## <int> <dbl> <dbl> <int> <int>
## 1 1 0 3 0 20
## 2 1 1 3 0 0
## 3 1 2 3 0 1
## 4 1 3 3 0 0
## 5 1 4 3 0 0
## 6 1 5 3 0 0
## # ... with 10 more variables: num_diff_resp <int>, num_same_trials <int>,
## # num_diff_trials <int>, hit <int>, fa <int>, cr <int>, miss <int>,
## # d_p <dbl>, response_type <chr>, number_resp <dbl>
ggplot(basicLevelFeature_longform, aes(x = response_type, y = number_resp, color = response_type))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(feature_index~level_diff,nrow = 3,strip.position = "bottom")+
labs(title="Proportaion response type by difficulty level", x = "level diff", y = "proportion")+
theme_facet()
## Warning: Removed 308 rows containing non-finite values (stat_boxplot).
## Warning: Removed 308 rows containing missing values (geom_point).

reaction time and difficulty levels
summarize = dplyr::summarize
responseData = totalData %>%filter(keys>=0,accuracy==1)
ggplot(responseData, aes(x = level_diff, y = rt, group = as.factor(level_diff), color = as.factor(level_diff)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type by difficulty levels", x = "response type", y = "RT (ms)")+
plotformat
## Warning: Removed 3 rows containing non-finite values (stat_boxplot).
## Warning: Removed 3 rows containing missing values (geom_point).

responseData_firstHalf = totalData %>%filter(keys>=0,accuracy==1,trialNum<42)
ggplot(responseData_firstHalf, aes(x = level_diff, y = rt, group = as.factor(level_diff), color = as.factor(level_diff)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type by difficulty levels -first", x = "response type", y = "RT (ms)")+
plotformat
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing missing values (geom_point).

responseData_lastHalf = totalData %>%filter(keys>=0,accuracy==1,trialNum>42)
ggplot(responseData_lastHalf, aes(x = level_diff, y = rt, group = as.factor(level_diff), color = as.factor(level_diff)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type by difficulty levels -last", x = "response type", y = "RT (ms)")+
plotformat
## Warning: Removed 2 rows containing non-finite values (stat_boxplot).
## Warning: Removed 2 rows containing missing values (geom_point).

#temp = responseData %>% group_by(subID, level_diff, feature_index) %>%summarise(mean_RT = mean(rt))
#ggplot(temp,aes(x = level_diff, y = mean_RT, group = level_diff))+
# geom_boxplot(fill = "white",lwd = 1)+
# geom_jitter(width=0.2,alpha = 0.5)+
# facet_wrap(~feature_index)+
# labs(title="Proportaion response type", x = "response type", y = "RT (ms)")+
# plotformat
######
responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==0)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for same pairs by levels", x = "levels", y = "RT (ms)")+
plotformat

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==1)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 1", x = "levels", y = "RT (ms)")+
plotformat

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==2)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 2", x = "levels", y = "RT (ms)")+
plotformat

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==3)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 3", x = "levels", y = "RT (ms)")+
plotformat

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==4)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 4", x = "levels", y = "RT (ms)")+
plotformat
## Warning: Removed 1 rows containing non-finite values (stat_boxplot).
## Warning: Removed 1 rows containing missing values (geom_point).

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==5)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 5", x = "levels", y = "RT (ms)")+
plotformat

responseData = totalData %>%filter(keys>=0,accuracy==1,level_diff==6)
ggplot(responseData, aes(x = pairIdentity, y = rt, group = as.factor(pairIdentity), color = as.factor(pairIdentity)))+
geom_boxplot(fill = "white",lwd = 1)+
geom_jitter(width=0.2,alpha = 0.5)+
facet_wrap(~feature_index)+
ylim(0,2500)+
labs(title="Reaction type for difference -- level 6", x = "levels", y = "RT (ms)")+
plotformat
## Warning: Removed 2 rows containing non-finite values (stat_boxplot).
## Warning: Removed 2 rows containing missing values (geom_point).
